home *** CD-ROM | disk | FTP | other *** search
- head 1.1;
- branch ;
- access ;
- symbols ;
- locks jhh:1.1; strict;
- comment @ * @;
-
-
- 1.1
- date 91.04.14.22.08.17; author jhh; state Exp;
- branches ;
- next ;
-
-
- desc
- @@
-
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @/*
- * nullfile.c --
- *
- * Description.
- *
- * Copyright 1989 Regents of the University of California
- * Permission to use, copy, modify, and distribute this
- * software and its documentation for any purpose and without
- * fee is hereby granted, provided that the above copyright
- * notice appear in all copies. The University of California
- * makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without
- * express or implied warranty.
- */
-
- #ifndef lint
- static char rcsid[] = "$Header: /sprite/lib/forms/RCS/proto.c,v 1.2 89/01/07 04:12:18 rab Exp $ SPRITE (Berkeley)";
- #endif /* not lint */
-
- #include <stdio.h>
- #include <stdlib.h>
-
- #define min(a,b) (((a) < (b)) ? (a) : (b) )
- #define BUFFER_SIZE 4096
-
- static char *progName;
-
- void Usage();
-
-
- /*
- *----------------------------------------------------------------------
- *
- * main--
- *
- * <description>
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
- void
- main(argc, argv)
- int argc;
- char *argv[];
- {
- char *name;
- int count;
- FILE *fp;
- static char buffer[BUFFER_SIZE];
- int bytesWritten;
- int bytesToWrite;
-
- progName = argv[0];
- if (argc != 3) {
- Usage();
- }
- name = argv[1];
- if (sscanf(argv[2], " %d", &count) != 1) {
- Usage();
- }
- if (count < 0) {
- fprintf(stderr,"Count argument must be positive.\n");
- Usage();
- }
- fp = fopen(name,"w+");
- if (fp == NULL) {
- fprintf(stderr,"Unable to open file %s.\n", name);
- exit(1);
- }
- bzero(buffer, BUFFER_SIZE);
- for (bytesWritten = 0; bytesWritten < count;) {
- bytesToWrite = min(BUFFER_SIZE, count - bytesWritten);
- fwrite(buffer, sizeof(char), bytesToWrite, fp);
- bytesWritten += bytesToWrite;
- }
- fclose(fp);
- }
-
-
- /*
- *----------------------------------------------------------------------
- *
- * Usage --
- *
- * description.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
- void
- Usage()
- {
- (void) fprintf(stderr,"Usage: %s file count\n",progName);
- exit(1);
- }
- @
-